﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Net;

namespace LookupTools
{
    class Program
    {
        static void Main(string[] args)
        {
            #region Lettura Argomenti
            //Lista Argomenti
            if ((args.Length == 0) | (args.Length > 2))
            {
                Console.WriteLine("Errore di Sintassi:  lookuptools.exe <inputfilename> <outputfilename>");
                return;
            }
            string InputFileName;
            string OutputFileName;
            // TODO: Sistemare Parser degli argomenti
            //modooperativo = args[0].ToString();
            InputFileName = args[0].ToString();
            OutputFileName = args[1].ToString();
            #endregion

            StreamReader InputFile = new StreamReader(InputFileName);
            StreamWriter OutputFile = new StreamWriter(OutputFileName);
            string linea = InputFile.ReadLine();
            while (linea != null)
            {
                Console.WriteLine("Processo " + linea);
                try
                {
                    IPHostEntry iphost = Dns.GetHostEntry(IPAddress.Parse(linea));
                    OutputFile.WriteLine(linea + ";" + iphost.HostName.ToString());
                }
                catch
                {
                    OutputFile.WriteLine(linea + ";" + "Errore");
                }
                
                
                linea = InputFile.ReadLine();
            }
            InputFile.Close();
            OutputFile.Close();
        }
    }
}
